/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bean;

import entities.User;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import org.icefaces.application.PushRenderer;
import other.Costants;

/**
 *
 * @author alessandro
 */
@ManagedBean(name="chatUserBean")
@ApplicationScoped
public class ChatUserBean implements Serializable {

    private List<String> userList = new ArrayList<String>(0);

    public ChatUserBean() {
        //PushRenderer.addCurrentSession(Costants.PUSH_GROUP);
    }

    public List<String> getUserList() {
        return userList;
    }

    public void setUserList(List<String> userList) {
        this.userList = userList;
    }

   public void addToList(String username) {
       if(userList.indexOf(username) < 0 && !"".equals(username)) {
           userList.add(username);
       }
       PushRenderer.render(Costants.PUSH_GROUP);
   }

   public void removeFromList(String username) {
       userList.remove(username);
       System.out.println("Rimosso user:" + username);
       PushRenderer.render(Costants.PUSH_GROUP);
   }

   public void stopView() {
       //.removeCurrentSession(Costants.PUSH_GROUP_LIST);
   }

}
